using ASP;
using HoWave.Web;
using HoWave.Web.Admin;
using System;
using System.Data;
using System.Web.Profile;
using System.Web.SessionState;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
public class HL_Admin_Admin_CityAreaEdit : Admin, IRequiresSessionState
{
	protected DropDownList DropDownList_Province;
	protected TextBox TextBox_City;
	protected HtmlTableRow tr1;
	protected DropDownList DropDownList_Flag;
	protected HtmlTableRow tr3;
	protected Button Button_OK;
	protected HtmlTableRow tr4;
	protected DefaultProfile Profile
	{
		get
		{
			return (DefaultProfile)this.Context.Profile;
		}
	}
	protected global_asax ApplicationInstance
	{
		get
		{
			return (global_asax)this.Context.ApplicationInstance;
		}
	}
	protected void Page_Load(object sender, EventArgs e)
	{
		if (!base.IsPostBack)
		{
			this.AllCityBind();
			if (base.Request.QueryString["Model"].ToString() == "_Edit")
			{
				int iD = int.Parse(base.Request.QueryString["ID"].ToString());
				Shop_City shop_City = new Shop_City();
				DataTable cityByID = shop_City.GetCityByID(iD);
				this.DropDownList_Province.Items.FindByText(cityByID.Rows[0]["Province"].ToString()).Selected = true;
				this.TextBox_City.Text = cityByID.Rows[0]["City"].ToString();
				if (Convert.ToBoolean(cityByID.Rows[0]["Flag"]))
				{
					this.DropDownList_Flag.SelectedValue = "1";
				}
				else
				{
					this.DropDownList_Flag.SelectedValue = "0";
				}
			}
		}
	}
	protected void AllCityBind()
	{
		Shop_City shop_City = new Shop_City();
		this.DropDownList_Province.DataSource = shop_City.GetAllProvince();
		this.DropDownList_Province.DataBind();
	}
	protected void Button_OK_Click(object sender, EventArgs e)
	{
		try
		{
		}
		catch (Exception)
		{
			throw;
		}
		string text = this.TextBox_City.Text;
		string selectedValue = this.DropDownList_Province.SelectedValue;
		bool flag = Convert.ToBoolean(this.DropDownList_Flag.SelectedValue);
		Shop_City shop_City = new Shop_City();
		if (text == "" || text == null)
		{
			this.WriteErrMsg("", "城市不能为空！", "");
		}
		if (base.Request.QueryString["Model"].ToString() == "_Edit")
		{
			int iD = int.Parse(base.Request.QueryString["ID"].ToString());
			shop_City.UpdateCity(selectedValue, text, "", "", flag, iD);
		}
		else
		{
			shop_City.AddCity(selectedValue, text, "", "", flag);
		}
		this.WriteSuccessMsg("", "操作成功！", "javascript:{window.returnValue=true;window.close();}");
	}
}
